home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / misc / ShipSwitcher.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  10.4 KB  |  300 lines

  1. class classes.misc.ShipSwitcher
  2. {
  3.    var shipType;
  4.    var x;
  5.    var y;
  6.    var routine;
  7.    var whichBro;
  8.    var tempLevel;
  9.    var shrapType1;
  10.    var shrapType2;
  11.    var c = 0;
  12.    var shipGift = false;
  13.    var Name = "shipSwitcher";
  14.    function ShipSwitcher(pshipType, px, py)
  15.    {
  16.       this.shipType = pshipType;
  17.       this.x = px;
  18.       this.y = py;
  19.       if(_root.char == "broShip1" || _root.char == "broShip2")
  20.       {
  21.          this.routine = "shipToShip";
  22.       }
  23.       else
  24.       {
  25.          this.routine = "jetpackToShip";
  26.       }
  27.       this.whichBro = !(_root.char == "broShip1" || _root.char == "bro1") ? "bro2" : "bro1";
  28.    }
  29.    function shipToShip()
  30.    {
  31.       this.c = this.c + 1;
  32.       _root.c = _root.c - 1;
  33.       if(this.c == 1)
  34.       {
  35.          _root[_root.char].positionForSwitch(_root.newShipClip._x - 103);
  36.       }
  37.       if(this.c == 30)
  38.       {
  39.          _root[_root.char + "Clip"].body.gotoAndPlay("open");
  40.          _root.newShipClip.ship.gotoAndPlay("open");
  41.       }
  42.       if(this.c == 52)
  43.       {
  44.          _root.d = _root.d + 1;
  45.          _root.attachMovie(this.whichBro + "Switcher","jetPackBro",_root.d++);
  46.          _root.jetPackBro._x = _root[_root.char].x + 15;
  47.          _root.jetPackBro._y = _root[_root.char].y + 3;
  48.          if(_root.char2 == "bro1")
  49.          {
  50.             _root.newShipClip.swapDepths(500050);
  51.             _root.bro1 = new classes.bro.Bro1(-40,_root.newShipClip._y - 57);
  52.             _root.addChar("bro1");
  53.             _root.bro1.getInOldShipA();
  54.             this.shipGift = true;
  55.             _root.tempShipLevel = _root.bro2ShipLevel <= 3 ? _root.bro2ShipLevel + 3 : _root.bro2ShipLevel - 3;
  56.             _root.tempShipVar = _root.bro2ShipVar;
  57.             _root.tempLife = _root.bro2Life;
  58.          }
  59.          else if(_root.char2 == "bro2")
  60.          {
  61.             _root.newShipClip.swapDepths(500050);
  62.             _root.bro2 = new classes.bro.Bro2(-40,_root.newShipClip._y - 57);
  63.             _root.addChar("bro2");
  64.             _root.bro2.getInOldShipA();
  65.             this.shipGift = true;
  66.             _root.tempShipLevel = _root.bro1ShipLevel <= 3 ? _root.bro1ShipLevel + 3 : _root.bro1ShipLevel - 3;
  67.             _root.tempShipVar = _root.bro1ShipVar;
  68.             _root.tempLife = _root.bro1Life;
  69.          }
  70.       }
  71.       if(this.c == 55)
  72.       {
  73.          var _loc8_ = _root[_root.char].x;
  74.          var _loc7_ = _root[_root.char].y;
  75.          _root[_root.char + "Clip"]._x = _root[_root.char].x = _root[_root.char].tX = _root.newShipClip._x;
  76.          _root[_root.char + "Clip"]._y = _root[_root.char].y = _root[_root.char].tY = _root.newShipClip._y;
  77.          _root.newShipClip._x = _loc8_;
  78.          _root.newShipClip._y = _loc7_;
  79.          if(_root.char == "bro2" || _root.char == "broShip2")
  80.          {
  81.             _root.newShipClip.gotoAndStop("oldShip2");
  82.             if(_root.bro2ShipVar == 1)
  83.             {
  84.                _root.newShipClip.shipStyles.gotoAndStop(_root.bro2ShipLevel);
  85.                if(this.shipType != "ship3B")
  86.                {
  87.                   _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(Number(this.shipType.charAt(4)));
  88.                }
  89.                else
  90.                {
  91.                   _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(8);
  92.                }
  93.             }
  94.             else
  95.             {
  96.                _root.newShipClip.shipStyles.gotoAndStop(_root.bro2ShipVar);
  97.                _root.tempVar2 = _root.bro2ShipVar;
  98.                _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(8);
  99.             }
  100.             this.tempLevel = _root.bro2ShipLevel;
  101.          }
  102.          else
  103.          {
  104.             _root.newShipClip.gotoAndStop("oldShip1");
  105.             if(_root.bro1ShipVar == 1)
  106.             {
  107.                _root.newShipClip.shipStyles.gotoAndStop(_root.bro1ShipLevel);
  108.                if(this.shipType != "ship3B")
  109.                {
  110.                   _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(Number(this.shipType.charAt(4)));
  111.                }
  112.                else
  113.                {
  114.                   _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(8);
  115.                }
  116.             }
  117.             else
  118.             {
  119.                _root.newShipClip.shipStyles.gotoAndStop(_root.bro1ShipVar);
  120.                _root.tempVar2 = _root.bro1ShipVar;
  121.                _root[_root.char + "Clip"].body.shipStyles.gotoAndStop(8);
  122.             }
  123.             this.tempLevel = _root.bro1ShipLevel;
  124.          }
  125.          _root.newShipClip.shipStyles.ship.gotoAndStop("open2");
  126.          _root[_root.char + "Clip"].body.shipStyles.ship.gotoAndStop("open2");
  127.       }
  128.       if(this.c == 100)
  129.       {
  130.          _root.jetPackBro.removeMovieClip();
  131.          if(!this.shipGift)
  132.          {
  133.             _root.newShipClip.shipStyles.ship.gotoAndPlay("close");
  134.          }
  135.          _root[_root.char].shipUpgrade(this.shipType);
  136.       }
  137.       if(this.c == 120)
  138.       {
  139.          _root[_root.char].control = true;
  140.       }
  141.       if(this.c > 120)
  142.       {
  143.          _root.c = _root.c + 1;
  144.          if(!this.shipGift)
  145.          {
  146.             _root.newShipClip._y -= 2;
  147.             var _loc3_ = false;
  148.             var _loc5_ = 0;
  149.             var _loc6_ = _root.broShots.length;
  150.             while(_loc5_ < _loc6_)
  151.             {
  152.                var _loc4_ = _root.broShots[_loc5_] + "Clip";
  153.                if(_root.newShipClip.hitTest(_root[_loc4_]))
  154.                {
  155.                   _root.removeBroShot(_root.broShots[_loc5_]);
  156.                   _loc3_ = true;
  157.                }
  158.                _loc5_ = _loc5_ + 1;
  159.             }
  160.             _loc5_ = 0;
  161.             _loc6_ = _root.enemyShots.length;
  162.             while(_loc5_ < _loc6_)
  163.             {
  164.                _loc4_ = _root.enemyShots[_loc5_] + "Clip";
  165.                if(_root.newShipClip.hitTest(_root[_loc4_]))
  166.                {
  167.                   _loc3_ = true;
  168.                }
  169.                _loc5_ = _loc5_ + 1;
  170.             }
  171.             _loc5_ = 0;
  172.             _loc6_ = _root.chars.length;
  173.             while(_loc5_ < _loc6_)
  174.             {
  175.                _loc4_ = _root.chars[_loc5_] + "Clip";
  176.                if(_root.newShipClip.hitTest(_root[_loc4_]))
  177.                {
  178.                   _loc3_ = true;
  179.                }
  180.                _loc5_ = _loc5_ + 1;
  181.             }
  182.             if(_loc3_)
  183.             {
  184.                if(random(2) == 1)
  185.                {
  186.                   _root.audio.playLevel2("broShip1X",_root.randRange(23,32));
  187.                }
  188.                else
  189.                {
  190.                   _root.audio.playLevel2("broShip2X",_root.randRange(23,32));
  191.                }
  192.                _loc5_ = 0;
  193.                _loc6_ = _root.randRange(5,8);
  194.                while(_loc5_ < _loc6_)
  195.                {
  196.                   _root.createExploA([_root.newShipClip._x + _root.newShipClip._width / 2 + _root.randRange(-50,50),_root.newShipClip._y + _root.newShipClip._height / 2 + _root.randRange(-50,50),_root.randRange(60,120),_root.randRange(75,100)]);
  197.                   _loc5_ = _loc5_ + 1;
  198.                }
  199.                if(this.whichBro == "bro1")
  200.                {
  201.                   if(_root.tmpVar2 == 7)
  202.                   {
  203.                      this.shrapType1 = "broShipBlack";
  204.                      this.shrapType2 = "broShipBlackB";
  205.                   }
  206.                   else if(this.tempLevel > 3)
  207.                   {
  208.                      this.shrapType1 = "BroShip2_" + (this.tempLevel - 3);
  209.                      this.shrapType2 = "broShip2B_" + (this.tempLevel - 3);
  210.                   }
  211.                   else
  212.                   {
  213.                      this.shrapType1 = "BroShip1_" + this.tempLevel;
  214.                      this.shrapType2 = "broShip1B_" + this.tempLevel;
  215.                   }
  216.                }
  217.                else if(_root.tmpVar2 == 7)
  218.                {
  219.                   this.shrapType1 = "BroShipBlack";
  220.                   this.shrapType2 = "broShipBlackB";
  221.                }
  222.                else if(this.tempLevel > 3)
  223.                {
  224.                   this.shrapType1 = "BroShip1_" + (this.tempLevel - 3);
  225.                   this.shrapType2 = "broShip1B_" + (this.tempLevel - 3);
  226.                }
  227.                else
  228.                {
  229.                   this.shrapType1 = "BroShip2_" + this.tempLevel;
  230.                   this.shrapType2 = "broShip2B_" + this.tempLevel;
  231.                }
  232.                _loc5_ = 0;
  233.                while(_loc5_ < 5)
  234.                {
  235.                   _root.createShrapnel([_root.newShipClip._x + _root.newShipClip._width / 2,_root.newShipClip._y + _root.newShipClip._height / 2,this.shrapType1]);
  236.                   _root.createShrapnel([_root.newShipClip._x + _root.newShipClip._width / 2,_root.newShipClip._y + _root.newShipClip._height / 2,this.shrapType2]);
  237.                   _loc5_ = _loc5_ + 1;
  238.                }
  239.                _root.newShipClip.removeMovieClip();
  240.             }
  241.          }
  242.       }
  243.       if(this.c > 400)
  244.       {
  245.          if(!this.shipGift)
  246.          {
  247.             _root.newShipClip.removeMovieClip();
  248.          }
  249.          _root.removeFX("shipSwitcher");
  250.       }
  251.    }
  252.    function jetpackToShip()
  253.    {
  254.       this.c = this.c + 1;
  255.       _root.c = _root.c - 1;
  256.       if(this.c == 1)
  257.       {
  258.          _root[_root.char].positionForSwitch(_root.newShipClip._y - 57);
  259.       }
  260.       if(this.c == 20)
  261.       {
  262.          _root.newShipClip.swapDepths(500050);
  263.          _root.newShipClip.ship.gotoAndPlay("open");
  264.       }
  265.       if(this.c == 30)
  266.       {
  267.          _root[_root.char].getInShip(_root.newShipClip._y + 3);
  268.       }
  269.       if(this.c == 38)
  270.       {
  271.          if(this.whichBro == "bro1")
  272.          {
  273.             _root.removeChar("bro1");
  274.             _root.broShip1 = new classes.bro.BroShip1(_root.newShipClip._x,_root.newShipClip._y);
  275.             _root.addChar("broShip1");
  276.             _root.char = "broShip1";
  277.          }
  278.          else
  279.          {
  280.             _root.removeChar("bro2");
  281.             _root.broShip2 = new classes.bro.BroShip2(_root.newShipClip._x,_root.newShipClip._y);
  282.             _root.addChar("broShip2");
  283.             _root.char = "broShip2";
  284.          }
  285.          _root.newShipClip.removeMovieClip();
  286.          _root[_root.char].shipUpgrade(this.shipType);
  287.          _root.shield.tagTeam();
  288.       }
  289.       if(this.c == 58)
  290.       {
  291.          _root[_root.char].control = true;
  292.          _root.removeFX("shipSwitcher");
  293.       }
  294.    }
  295.    function main()
  296.    {
  297.       this[this.routine]();
  298.    }
  299. }
  300.